﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
namespace QLVT
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class HangHoaWindow : Window
    {
        public HangHoaWindow()
        {
            InitializeComponent();
        }
        private HangHoa hanghoa = new HangHoa();
        private HoaDon hoadon = new HoaDon();
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            DataTable dt = hanghoa.DanhSachHangHoa();
            cboHangHoa.ItemsSource = dt.DefaultView;
            cboHangHoa.DisplayMemberPath = "tenhang";
            cboHangHoa.SelectedValuePath = "mahang";
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string sohd = txtSoHD.Text;
            string mahang = cboHangHoa.SelectedValue.ToString();
            string diendiai = txtDienGiai.Text;
            double sl = double.Parse(txtSoLuong.Text);
            double dg = double.Parse(txtDonGia.Text);
            hoadon.LuuHoaDon(sohd, mahang, diendiai, sl, dg);
            txtSoHD.Text = "";
            txtDonGia.Text = "";
            txtSoLuong.Text = "";
            txtDienGiai.Text = "";
            txtSoHD.Focus();
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Close();
        }

    }
}
